#[allow(unused_imports)]
use crate::{framework::GameApp, util::KeyboardState};

#[test]
fn test_run_with_render() {
    let mut game = GameApp::build(
        true,
        true,
        true
    );
    let mut i_keyboard_state = KeyboardState::new();
    game.initialize();

    loop {
        i_keyboard_state.query(
            game.get_window()
        );
        game.step(
            i_keyboard_state.as_raw_ptr(),
            0.0167,
        );
        let info = game.get_game_info_ptr();
        unsafe {
            if (*info).cactus_count != 0 {
                println!("cactus_count:{}", (*info).cactus_count);
                for i in 0..(*info).cactus_count {
                    println!("cactuses:{:?}", *(*info).cactuses.add(i as _));
                }
            }

            if (*info).pterosaur_count != 0 {
                println!("pterosaur_count:{}", (*info).pterosaur_count);
                for i in 0..(*info).pterosaur_count {
                    println!("pterosaurs:{:?}", *(*info).pterosaurs.add(i as _));
                }
            }

            if (*info).meteorite_count != 0 {
                println!("meteorite_count:{}", (*info).meteorite_count);
                for i in 0..(*info).meteorite_count {
                    println!("meteorites:{:?}", *(*info).meteorites.add(i as _));
                }
            }
        };

        let mut tmp = String::new();
        std::io::stdin().read_line(&mut tmp).unwrap();
    }
}

#[test]
fn test_run_no_render() {
    let mut game = GameApp::build(
        false,
        false,
        true
    );
    let mut i_keyboard_state = [0; 108];
    game.initialize();


    loop {
        game.step(
            i_keyboard_state.as_mut_ptr(),
            0.0167,
        );
        let info = game.get_game_info_ptr();
        unsafe {
            if (*info).cactus_count != 0 {
                println!("cactus_count:{}", (*info).cactus_count);
                for i in 0..(*info).cactus_count {
                    println!("cactuses:{:?}", *(*info).cactuses.add(i as _));
                }
            }

            if (*info).pterosaur_count != 0 {
                println!("pterosaur_count:{}", (*info).pterosaur_count);
                for i in 0..(*info).pterosaur_count {
                    println!("pterosaurs:{:?}", *(*info).pterosaurs.add(i as _));
                }
            }

            if (*info).meteorite_count != 0 {
                println!("meteorite_count:{}", (*info).meteorite_count);
                for i in 0..(*info).meteorite_count {
                    println!("meteorites:{:?}", *(*info).meteorites.add(i as _));
                }
            }
        };

        let mut tmp = String::new();
        std::io::stdin().read_line(&mut tmp).unwrap();
    }
}